<template>
    <div class="content">
        <div class="sensor_title">
            <span v-if="sensorInfo.sensor_name">{{ sensorInfo.sensor_name + sensorInfo.direction }}</span>
            <span v-else>请选择传感器</span>
        </div>
        <div class="content_bottom" v-if="sensorInfo.id">
            <div class="sensor_item">
                <!-- <div class="item_title">基础数据</div> -->
                <div class="item_sensor_type">
                    <span>类型</span>
                    <span>{{ sensorInfo.sensor_type_name }}</span>
                </div>
                <div class="item_sight item_sight1">
                    <span>地址号</span>
                    <span>{{ sensorInfo.address }}</span>
                </div>
                <div class="item_sight item_sight1">
                    <span>端口号</span>
                    <span>{{ sensorInfo.port }}</span>
                </div>
                <div class="item_sight item_sight1">
                    <span>状态</span>
                    <span>{{ sensorInfo.status }}</span>
                </div>
            </div>
            <div class="nowData">
                <mqtt-data ref="mqttData" :sensorInfo="sensorInfo" @setStatus="setStatus" />
            </div>

            <div class="alarm">
                <div class="title">
                    <span style="color: #007bff">告警总数:</span>
                    <span style="fontsize: 22px; fontweight: 600; color: #00ffff">
                        {{ sensorInfo.warn.length }}
                    </span>
                </div>
                <div class="notice_item">
                    <span>严重</span>
                    <span style="color: #fe0000">
                        {{
                            sensorInfo.warn.filter((e) => {
                                return e.warn_level == 3
                            }).length
                        }}
                    </span>
                </div>
                <div class="notice_item">
                    <span>中等</span>
                    <span style="color: #db0b99">
                        {{
                            sensorInfo.warn.filter((e) => {
                                return e.warn_level == 2
                            }).length
                        }}
                    </span>
                </div>
                <div class="notice_item">
                    <span>一般</span>
                    <span style="color: #feff00">
                        {{
                            sensorInfo.warn.filter((e) => {
                                return e.warn_level == 1
                            }).length
                        }}
                    </span>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import mqttData from '@/components/mqttData'
export default {
    data() {
        return {
            //特征值相关
            eigenvalue: {
                tags: [],
                // 某一特征值最近数据
                recentData: [],
                RecentDataisShow: false,
            },

            realTimeData: {},
        }
    },

    props: ['father_1'],
    components: {
        mqttData,
    },
    computed: {
        sensorInfo() {
            return JSON.stringify(this.father_1) === '{}' ? { warn: [], order: [] } : this.father_1
        },
    },

    methods: {
        setStatus(a) {

            this.sensorInfo.status = a
        },
    },
    created() {},
}
</script>

<style lang="less" scoped>
.content {
    width: 100%;
    height: 100%;
    position: relative;

    .sensor_title {
        position: absolute;
        left: 0;
        top: 10px;
        width: 100%;
        height: 28px;
        line-height: 28px;
        text-align: center;
        color: aqua;
        font-size: 22px;
        font-weight: 600;
    }

    .content_bottom {
        width: 96%;
        height: calc(100% - 46px);
        position: absolute;
        // background-color: pink;
        top: 40px;
        left: 2%;
        overflow: auto;

        .compareData {
            // height: 60px;
            margin-bottom: 20px;
            width: 100%;

            .com_item {
                width: 100%;
                height: 64px;
                display: flex;
                justify-content: space-between;

                .item {
                    background-color: #04204c;
                    width: 35%;
                    height: 100%;
                    color: #b2e3ff;
                    text-align: center;
                    display: flex;
                    flex-direction: column;
                    justify-content: space-around;
                    font-size: 14px;
                    border: 1px dashed #007bff;
                    border-radius: 4px;
                    margin-bottom: 2px;

                    span:nth-child(1) {
                        font-weight: 600;
                    }

                    span:nth-child(2) {
                        color: #0cd9e8;
                    }
                }

                .item_start {
                    width: 25%;
                }
            }
        }

        .alarm {
            .title {
                width: 94%;
                height: 36px;
                line-height: 36px;
                font-weight: 600;
                text-indent: 10px;
                display: flex;
                justify-content: space-between;
            }

            .notice_item {
                transition: all 0.3s;
                cursor: pointer;
                width: 30%;
                height: 60px;
                background-color: rgba(96, 142, 235, 0.1);
                background-image: url(@/assets/common/form_item_bg.png);
                background-size: 100% 100%;
                float: left;
                margin-left: 3%;
                position: relative;

                span:nth-child(1) {
                    position: absolute;
                    color: #b2e3ff;
                    font-weight: 400;
                    width: 80%;
                    top: 10px;
                    left: 10%;
                    text-align: center;
                }

                span:nth-child(2) {
                    color: #00ffff;
                    position: absolute;
                    font-weight: 600;
                    font-size: 22px;
                    width: 100%;
                    text-align: center;
                    bottom: 10px;
                }
            }

            .notice_item1 {
                width: 44%;
                margin-left: 4%;
            }
        }

        .sensor_item {
            width: 100%;
            // background-color: red;
            margin: 0;
            overflow: hidden;

            .item_sight {
                width: 30%;
                float: left;
                margin-left: 2%;
                margin-bottom: 6px;
                background-color: rgba(96, 142, 235, 0.1);
                background-image: url(@/assets/common/form_item_bg.png);
                background-size: 100% 100%;
                height: 70px;
                position: relative;
                transition: all 0.3s;
                cursor: pointer;

                span:nth-child(1) {
                    color: #b2e3ff;

                    font-weight: 800;
                    text-align: center;
                    width: 100%;
                    position: absolute;
                    top: 30%;
                    font-size: 14px;
                }

                span:nth-child(2) {
                    color: #00ffff;
                    font-weight: 500;
                    text-align: center;
                    width: 100%;
                    position: absolute;
                    top: 60%;
                }
            }

            .item_sensor_type {
                width: 100%;
                height: 80px;
                margin-top: 10px;
                background-image: url(@/assets/common/form_item_bg.png);
                background-size: 100% 100%;

                span:nth-child(1) {
                    display: block;
                    color: #b2e3ff;
                    font-weight: 800;
                    text-align: center;
                    width: 100%;
                    height: 40%;
                    line-height: 48px;
                }

                span:nth-child(2) {
                    height: 50%;
                    line-height: 40px;
                    display: block;
                    color: #0cd9e8;
                    font-weight: 800;
                    text-align: center;
                    width: 100%;
                    font-size: 20px;
                }
            }

            .item_sight:hover {
                transform: scale(1.1);
                box-shadow: 0 0 1rem rgba(102, 244, 229, 0.5);
            }
        }

        .nowData {
            margin-bottom: 4px;
            width: 100%;
            overflow: hidden;
        }
    }
}

.recentData {
    width: 100%;
    height: calc(100vh - 300px);
}
</style>
